<%--
  Created by IntelliJ IDEA.
  User: lqs
  Date: 2023/8/30
  Time: 15:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
    <style>
        .disabled-button {
            pointer-events: none;
            opacity: 0.5; /* 可选择添加半透明效果，以凸显不可点击的状态 */
            cursor: not-allowed; /* 可选择添加不允许的光标样式 */
        }
    </style>
</head>

<body>
<form action="/add" method="post" onsubmit="return validateForm()">
  用户名:<input type="text" name="username" id="username" onblur="the1()">

    <div id="c1"><span ></span></div><br>

  密码：<input type="password" name="password" id="password"><br>
<%--  创建时间：<input type="password" name="createtime" ><br>--%>
  手机号：<input type="password" name="phone" id="phone"><br>
  <button type="submit" class="" id="c2">确定</button>
</form>
<a href="show">返回</a>
<script>
    function validateForm() {
        var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
        var phone = document.getElementById("phone").value;

        if (username == ""|| password==""||phone=="") {
            alert("不能为空");
            return false;
        }

    }
    function the1(){
        let username=document.getElementById("username").value;
        //创建对象
        $.post("getname",{"getname":username},(data)=> {

            if(data>0){
                c1s=$("#c1")
                b1s=$("#c2")
console.log(b1s[0].className)
                c1s[0].innerText="账号重复"
                b1s[0].className="disabled-button"
            }else {
                c1s[0].innerText="";
                b1s[0].className=""

            }


        })

    }
</script>
</body>
</html>
